package practiceProjects.TextIntoSqlString;

import java.io.*;

/**
 * @Project ：learn_java
 * @File ：TextIntoSqlString.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/5/7 20:07
 * @Description ：For study.
 */


public class TextIntoSqlString {

    public static void main(String[] args) {
        String inputPath = "F:\\codes\\learn_java\\src\\practiceProjects\\TextIntoSqlString\\input.txt";
        String outputPath = "F:\\codes\\learn_java\\src\\practiceProjects\\TextIntoSqlString\\output.txt";

        try (BufferedReader reader = new BufferedReader(new FileReader(inputPath));
             BufferedWriter writer = new BufferedWriter(new FileWriter(outputPath))) {

            String line;
            // 逐行读取输入文件
            while ((line = reader.readLine()) != null) {
                // 将读取的行写入输出文件
                // ！不要去除行尾空格，会出现语句拼接在一起的问题
                line = "+ \"" + line + "\"";
                writer.write(line);
                // 写入换行符
                writer.newLine();
            }
            System.out.println("文件操作成功！");
        } catch (IOException e) {
            System.err.println("文件操作过程中出现错误：" + e.getMessage());
        }
    }
}
